<UserControl  
    x:Class="ibba.src.noriskbo.PainelListaContratos"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vm="clr-namespace:ibba.src.noriskbo.ViewModels"
    xmlns:slc="clr-namespace:ibba.src.sl.componentes;assembly=ibba.src.sl.componentes"
    xmlns:slrv="clr-namespace:ibba.src.sl.recursos.Validations;assembly=ibba.src.sl.recursos"
    xmlns:local="clr-namespace:ibba.src.noriskbo"
    mc:Ignorable="d"
    d:DesignWidth="300" d:DesignHeight="300">

    <UserControl.Resources>
        <local:ResolveStrings x:Key="ResolveStrings"/>
        <slc:SwitchConverter x:Key="CheckIconConverter" 
                             Else="{StaticResource IconeMiniUnchecked}">
            <slc:SwitchCase When="True" Then="{StaticResource IconeMiniChecked}" />
        </slc:SwitchConverter>
    </UserControl.Resources>

        <Grid x:Name="LayoutRoot" Background="{x:Null}"> 

        <StackPanel Orientation="Horizontal">
            <Border BorderThickness="1,1,1,1" BorderBrush="{StaticResource BlueOpaco}" Background="#FFEFEFEF"
                    Visibility="{Binding ElementName=GridContratos, Path=Visibility, Converter={StaticResource NotVisibilityConverter}}">

                <Grid>
                    <Button x:Name="btnExibirFiltro" Width="21" Height="21"
                            Cursor="Hand" VerticalAlignment="Top" Margin="3,3,3,0"
                            ToolTipService.ToolTip="Expandir Filtro"
                            Click="btnExibirFiltro_Click">
                        <Image Source="{StaticResource BotaoProximo}" />
                    </Button>
                    <TextBlock Text="Filtro" Style="{StaticResource Rotate90}" FontSize="16" Foreground="Gray" Margin="2,80,-20,0" 
                               VerticalAlignment="Top" />
                </Grid>
            </Border>

            <Grid x:Name="GridContratos" Background="White">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <Border Grid.Row="0" Background="{StaticResource BlueStrong}" BorderBrush="#FFB5B6B5" BorderThickness="1">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Filtro" Foreground="White" FontSize="12" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="4,-4" />
                        <Border CornerRadius="5" BorderThickness="1" BorderBrush="#FF3C5D83" Background="#FFDCE8EF"
                                Margin="5" HorizontalAlignment="Left">
                            <StackPanel Orientation="Horizontal" >
                                <Image Name="imgFlagAT" Source="{StaticResource IconeFlagAT}" Height="10" Width="10" Cursor="Hand" Margin="10,-5,0,0" 
                                       ToolTipService.ToolTip="{Binding StringLibrary.OperacoesAutomaticas, Source={StaticResource ResolveStrings}}" MouseLeftButtonUp="chkFlagAT_MouseLeftButtonUp" />
                                <Image Name="chkFlagAT" Source="{Binding FiltrarStatusAutomatico, Mode=TwoWay, Converter={StaticResource CheckIconConverter}}"
                                       Height="16" Width="16" Cursor="Hand" Margin="-8,3,0,0"
                                       ToolTipService.ToolTip="{Binding StringLibrary.OperacoesAutomaticas, Source={StaticResource ResolveStrings}}" MouseLeftButtonUp="chkFlagAT_MouseLeftButtonUp" />
                                <TextBlock Text="|" Style="{StaticResource SubTitleHeader}" FontSize="10" VerticalAlignment="Center" Margin="1"/>

                                <Image Name="imgFlagEB" Source="{StaticResource IconeFlagEB}" Height="10" Width="10" Cursor="Hand" Margin="3,-5,0,0" 
                                       ToolTipService.ToolTip="{Binding StringLibrary.EmBaixaOperacional, Source={StaticResource ResolveStrings}}" MouseLeftButtonUp="chkFlagEB_MouseLeftButtonUp"/>
                                <Image Name="chkFlagEB" Source="{Binding FiltrarStatusEB, Mode=TwoWay, Converter={StaticResource CheckIconConverter}}"
                                       Height="16" Width="16" Cursor="Hand" Margin="-8,3,0,0" 
                                       ToolTipService.ToolTip="{Binding StringLibrary.EmBaixaOperacional, Source={StaticResource ResolveStrings}}" MouseLeftButtonUp="chkFlagEB_MouseLeftButtonUp"/>
                                
                                <Image Name="imgFlagBO" Source="{StaticResource IconeFlagBO}" Height="10" Width="10" Cursor="Hand" Margin="3,-5,0,0" 
                                       ToolTipService.ToolTip="{Binding StringLibrary.BaixaOperacional, Source={StaticResource ResolveStrings}}" MouseLeftButtonUp="chkFlagBO_MouseLeftButtonUp" />
                                <Image Name="chkFlagBO" Source="{Binding FiltrarStatusBO, Mode=TwoWay, Converter={StaticResource CheckIconConverter}}"
                                       Height="16" Width="16" Cursor="Hand" Margin="-8,3,0,0"
                                       ToolTipService.ToolTip="{Binding StringLibrary.BaixaOperacional, Source={StaticResource ResolveStrings}}" MouseLeftButtonUp="chkFlagBO_MouseLeftButtonUp" />                                
                                <TextBlock Text="|" Style="{StaticResource SubTitleHeader}" FontSize="10" VerticalAlignment="Center" Margin="1"/>
                                
                                <Image Name="imgFlagRA" Source="{StaticResource IconeFlagRA}" Height="10" Width="10" Cursor="Hand" Margin="3,-5,0,0" 
                                       ToolTipService.ToolTip="{Binding StringLibrary.OperacoesEmRascunho, Source={StaticResource ResolveStrings}}" MouseLeftButtonUp="chkFlagRA_MouseLeftButtonUp"/>
                                <Image Name="chkFlagRA" Source="{Binding FiltrarStatusRA, Mode=TwoWay, Converter={StaticResource CheckIconConverter}}"
                                       Height="16" Width="16" Cursor="Hand" Margin="-8,3,0,0" 
                                       ToolTipService.ToolTip="{Binding StringLibrary.OperacoesEmRascunho, Source={StaticResource ResolveStrings}}" MouseLeftButtonUp="chkFlagRA_MouseLeftButtonUp"/>

                                <Image Name="imgFlagEA" Source="{StaticResource IconeFlagEA}" Height="10" Width="10" Cursor="Hand" Margin="3,-5,0,0" 
                                       ToolTipService.ToolTip="{Binding StringLibrary.OperacoesEmAprovacao, Source={StaticResource ResolveStrings}}" MouseLeftButtonUp="chkFlagEA_MouseLeftButtonUp"/>
                                <Image Name="chkFlagEA" Source="{Binding FiltrarStatusEA, Mode=TwoWay, Converter={StaticResource CheckIconConverter}}"
                                       Height="16" Width="16" Cursor="Hand" Margin="-8,3,0,0" 
                                       ToolTipService.ToolTip="{Binding StringLibrary.OperacoesEmAprovacao, Source={StaticResource ResolveStrings}}" MouseLeftButtonUp="chkFlagEA_MouseLeftButtonUp" />

                                <Image Name="imgFlagEE" Source="{StaticResource IconeFlagEE}" Height="10" Width="10" Cursor="Hand" Margin="3,-5,0,0" 
                                       ToolTipService.ToolTip="{Binding StringLibrary.OperacoesEmExclusao, Source={StaticResource ResolveStrings}}" MouseLeftButtonUp="chkFlagEE_MouseLeftButtonUp"/>
                                <Image Name="chkFlagEE" Source="{Binding FiltrarStatusEE, Mode=TwoWay, Converter={StaticResource CheckIconConverter}}"
                                       Height="16" Width="16" Cursor="Hand" Margin="-8,3,0,0" 
                                       ToolTipService.ToolTip="{Binding StringLibrary.OperacoesEmExclusao, Source={StaticResource ResolveStrings}}" MouseLeftButtonUp="chkFlagEE_MouseLeftButtonUp" />

                                <Image Name="imgFlagAP" Source="{StaticResource IconeFlagAP}" Height="10" Width="10" Cursor="Hand" Margin="3,-5,0,0" 
                                       ToolTipService.ToolTip="{Binding StringLibrary.OperacoesAprovadas, Source={StaticResource ResolveStrings}}" MouseLeftButtonUp="chkFlagAP_MouseLeftButtonUp"/>
                                <Image Name="chkFlagAP" Source="{Binding FiltrarStatusAP, Mode=TwoWay, Converter={StaticResource CheckIconConverter}}"
                                       Height="16" Width="16" Cursor="Hand" Margin="-8,3,10,0" 
                                       ToolTipService.ToolTip="{Binding StringLibrary.OperacoesAprovadas, Source={StaticResource ResolveStrings}}" MouseLeftButtonUp="chkFlagAP_MouseLeftButtonUp" />

                            </StackPanel>
                        </Border>
                        <Button x:Name="btnMinimizarFiltro" Width="21" Height="21"
                                Cursor="Hand" HorizontalAlignment="Right" VerticalAlignment="Center"
                                ToolTipService.ToolTip="Minimizar Filtro" Margin="5" Click="btnMinimizarFiltro_Click">
                            <Image Source="{StaticResource BotaoAnterior}" />
                        </Button>
                    </StackPanel>
                </Border>

                <Border Grid.Row="2" BorderThickness="1" BorderBrush="#FF6B696B" Background="#FFB5B6B5" Padding="5">
                    <Grid>
                        <TextBox x:Name="txtCriterioFiltro" Margin="0,0,0,0" Padding="0,2,25,0"
                                 Text="{Binding FiltrarContrato, Mode=TwoWay}"
                                 slrv:TextBoxUpdateSourceService.UpdateBindingOnChanged="True"/>
                        <Image x:Name="imgPesquisaFiltro" Source="{StaticResource BotaoPesquisar}" 
                               Width="19" Height="19" HorizontalAlignment="Right" Margin="0,2,2,2"
                               Visibility="{Binding ElementName=btnLimparFiltro, Path=Visibility, Converter={StaticResource NotVisibilityConverter}}"/>

                        <Button x:Name="btnLimparFiltro" BorderBrush="#FFADAAAD" BorderThickness="0"
                                HorizontalAlignment="Right" ToolTipService.ToolTip="Limpar" 
                                Width="19" Height="19" Cursor="Hand" Margin="0,2,2,2" Opacity="0.75" 
                                Click="btnLimparFiltro_Click"
                                Visibility="{Binding ElementName=txtCriterioFiltro, Path=Text.Length, Converter={StaticResource BooleanToVisibilityConverter}}">
                            <Image Source="{StaticResource BotaoExcluir}" />
                        </Button>
                    </Grid>
                </Border>

                <Border Grid.Row="1" Background="#FFEFEFEF" BorderBrush="#FFB5B6B5" BorderThickness="1,0" Padding="5">
                    <Border BorderBrush="#FFDBD8D8" BorderThickness="1" Padding="2" Background="White" CornerRadius="3">
                        <ListBox x:Name="lstContrato" BorderBrush="#FF6B696B" Background="White" BorderThickness="0" 
                                 ItemsSource="{Binding ContratosFiltrado}"
                                 SelectedItem="{Binding ContratoSelecionado, Mode=TwoWay}">
                            <!--SelectionChanged="lstContrato_SelectionChanged">-->
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel MinWidth="150">
                                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">
                                        <Image Source="{Binding Path=CodigoStatus, Converter={StaticResource StatusImageConverter}, ConverterParameter='mini'}" 
                                               Width="16" Height="16"/>
                                        <TextBlock Text="{Binding Mode=OneWay, Path=CodigoContrato}" Margin="3,0,0,0"/>
                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="20,0,0,0">
                                        <TextBlock Text="{Binding Path=CodigoProduto}" FontSize="9" Foreground="Blue" Margin="0,0,0,0" />
                                        <TextBlock Text="/" FontSize="9" Foreground="Black" Margin="5,0,0,0" FontWeight="Bold" />
                                        <TextBlock Text="{Binding Path=CodigoModalidade}" FontSize="9" Foreground="Blue" Margin="5,0,0,0" />
                                    </StackPanel>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    </Border>
                </Border>
            </Grid>
        </StackPanel>

    </Grid>
</UserControl>